Repository navigation
[Testing] Harden Appium force-close process lifecycle - #40835
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. Some pipeline(s) encountered errors during trigger evaluation. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…appium-force-close
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
AppiumProcessRunner leaves accessed output and error readers undisposed, leaking two pipe handles per RunAdb or force-close invocation until garbage collection.
1 open issue
What changed in this PR
This PR hardens Appium force-close and recovery commands in MAUI’s test infrastructure. It isolates the process-lifecycle work from #39621 without restoring direct fixture launch or changing navigation and session behavior.
Changes:
- Adds a shared process runner with concurrent output draining, bounded waits, process-tree termination, and structured failure results.
- Routes force-close and ADB recovery through the runner, reporting force-close failures while keeping recovery best-effort.
- Adds a standalone process fixture and lifecycle tests covering output volume, exits, timeouts, argument handling, and incomplete drains.
| File | Description |
|---|---|
src/TestUtils/tests/TestUtils.UnitTests/Program.cs |
Dispatches process-fixture modes before starting the test runner. |
src/TestUtils/tests/TestUtils.UnitTests/AppiumLifecycleProcessTests.cs |
Tests process lifecycle and force-close result handling. |
src/TestUtils/tests/TestUtils.UnitTests/AppiumLifecycleProcessFixture.cs |
Provides controlled output, exit, and child-process scenarios. |
src/TestUtils/src/UITest.Appium/Properties/AssemblyInfo.cs |
Exposes internal helpers to the unit-test assembly. |
src/TestUtils/src/UITest.Appium/AppiumProcessRunner.cs |
Centralizes process execution, draining, cleanup, and failure reporting. |
src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs |
Integrates the runner into platform force-close and ADB recovery. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Selected Tests
🧪 Test selection — click to expand
🧪 UI tests — the full suite on every platform❌ Could not queue GPT-6.2 Sol: Run the full UI suite on all four platforms because the PR changes shared Appium force-close and crash recovery. 🧪 Running — 77 categories on Android, iOS, MacCatalyst, WindowsThe complete 🧪 Device tests — nothing to runℹ️ The AI found no changes relevant to device tests, so no GPT-6.2 Sol: No device tests are needed for this Appium-only change. 🧪 Running — nothingNo device tests run for this PR. ⏭️ Skipped — what neither suite runsDevice tests — 105 categories, 4 platforms Platforms not run: Android, iOS, MacCatalyst, Windows Each skipped platform and project is listed as a 🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)UI testsEach model chose independently; every test that runs was selected by at least one of them.
GPT-6.2 Sol — Run the full UI suite on all four platforms because the PR changes shared Appium force-close and crash recovery.
MAI Code 2 — Shared Appium process-lifecycle infrastructure changes across UI test force-close and recovery paths; runs the full UI suite on all platforms.
Device testsEach model chose independently; every test that runs was selected by at least one of them.
GPT-6.2 Sol — No device tests are needed for this Appium-only change.
MAI Code 2 — No device suites are affected; the change is confined to Appium UI-test process infrastructure and its unit tests.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MAUI Autopilot — Retrying@kubaflo ❌ The fix round failed. The loop retries it once. Run. Error |

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
dd3381d1d3b331803f9379f5798c38356ff5383cTestUtils.UnitTestspassed 73 tests with 1 unrelated Windows-only skip; the 12 focused lifecycle tests passed.↑ An exact-source Linux .NET 11 probe confirmed
KillOnParentExit, bounded timeout, and removal of a live descendant within 10 seconds.↓ Actual simctl, ADB, pkill, and taskkill executions, Windows-native process-tree behavior, and a device-level Appium suite were not exercised.
Succeedednow fails unless the command exits zero and every drain/process cleanup succeeds.↑ The original force-close paths returned success despite timeout or nonzero exit and did not wait for redirected streams or termination.
↓ No real simulator, emulator, or Windows host execution confirms platform-tool integration.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target Branch
mainnet11, for reviewFor .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
Harden Appium force-close and recovery process execution without changing fixture launch behavior:
ProcessStartInfo.ArgumentListtransport forRunAdb, simctl termination, ADB force-stop, pkill, and taskkill.RunAdband 10-second force-close waits; terminate the whole process tree and wait boundedly after timeout; setKillOnParentExitonly on Windows and Linux.RunAdbbest-effort, but fail force-close closed for start, timeout, termination, drain, and nonzero-exit failures instead of returning success.This intentionally ports only the process-lifecycle portion previously bundled into #39621 and reverted with the broader direct-launch work. It does not reintroduce direct fixture launch, startup/session changes, navigation, or test-selection behavior, and it does not modify ShellHelper or ToolRunner.
Validation
dotnet format src/TestUtils/src/UITest.Appium/UITest.Appium.csproj --no-restore --include src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs src/TestUtils/src/UITest.Appium/AppiumProcessRunner.cs src/TestUtils/src/UITest.Appium/Properties/AssemblyInfo.cs --exclude-diagnostics CA1822 --verbosity minimal— passed.dotnet format src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-restore --include src/TestUtils/tests/TestUtils.UnitTests/Program.cs src/TestUtils/tests/TestUtils.UnitTests/AppiumLifecycleProcessFixture.cs src/TestUtils/tests/TestUtils.UnitTests/AppiumLifecycleProcessTests.cs --exclude-diagnostics CA1822 --verbosity minimal— passed.dotnet build src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-restore --nologo— passed with 0 warnings and 0 errors.dotnet test src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-build --no-restore --nologo— passed: 73 succeeded, 1 Windows-only test skipped, 0 failed on macOS arm64.dotnet test src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --no-build --no-restore --filter 'FullyQualifiedName~AppiumLifecycleProcessTests' --nologo— passed: 12/12 focused lifecycle tests.AppiumProcessRunner.cs— passed:KillOnParentExitwas enabled, the timed-out root failed, and its live child exited within 10 seconds.Platform gaps: local execution covered macOS arm64 and a Linux aarch64 container. Actual simctl, ADB, pkill, and taskkill commands, Windows-native process-tree/
KillOnParentExitbehavior, and device-level Appium UI runs were not exercised. The earlier UI-test dispatch did not queuemaui-pr-uitests.Issues Fixed
N/A — test infrastructure hardening; no issue was provided.
Let AI finish this PR